package xuesm.strategy.pay;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: xuesm
 * @Description: 支付策略类
 * @Date: Create in 20:02 2019/4/12
 */
public class PayStrategy {

	public static final String ALI_PAY = "ALiPay";
	public static final String WECHAT_PAY = "WeChatPay";
	public static final String UNION_PAY = "UnionPay";
	public static final String DEFAULT_PAY = ALI_PAY;


	private static Map<String, Payment> PAY_MAP = new HashMap<>();
	static {
		PAY_MAP.put(ALI_PAY, new AliPay());
		PAY_MAP.put(WECHAT_PAY, new WeChatPay());
		PAY_MAP.put(UNION_PAY, new UnionPay());
		PAY_MAP.put(DEFAULT_PAY, new AliPay());
	}

	public static Payment getPayment(String payKey){
		if (!PAY_MAP.containsKey(payKey)){
			return PAY_MAP.get(DEFAULT_PAY);
		}
		return PAY_MAP.get(payKey);
	}
}
